package comc.controller;


import comc.config.IgnoreUsersConfig;
import comc.pojo.User;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
//@RequestMapping("/user")
public class UserController extends GenericController{
    @Value("${server.port}")
    String nann;
//    private static final String REST_URL="http://SPRINGCLOUD-DEVT";//通过注册中心获取服务
//    @Autowired
//public RestTemplate restTemplate;
    @Autowired
public ControInterface controInterface;
    @Autowired
    User person1;
    @Autowired
    IgnoreUsersConfig ignoreUsersConfig;
//    @RequestMapping("/getOne/{id}")
//    public User getOneUser( @PathVariable int id){
//        return  restTemplate.getForObject(REST_URL+"/getOne/"+id,User.class);
//
//    }
//    @RequestMapping("/getAllUser")
//    public List<User> getUser(){
//        return  restTemplate.getForObject(REST_URL+"/getAllUser",List.class);
//    }

    @RequestMapping("/getUserByid2")
    public String getUser(@RequestBody JSONObject id){
        JSONObject jsonObject = JSONObject.fromObject(id);
        return  controInterface.getAllUser(jsonObject);
    }
    @RequestMapping("/getAllUser2")
    public String  getUser2(){
        return  controInterface.getAllUser2();
    }
    @RequestMapping("/getAllUser3")
    public String  getUser3(){
        if (person1==null){
            return "用户为空";
        }
        return  person1.toString();
    }
    @RequestMapping("/getAllUser4")
    public String  getUser4(){
        List<String> urls = ignoreUsersConfig.getUrls();
        System.out.println(ignoreUsersConfig.getName());
        for (String url : urls) {
            System.out.println(url);
        }
        System.out.println(nann+"=======");
        return  "ces";
    }
}
